import React, { Component } from 'react'

class Toggle extends Component {
  constructor(props) {
    super(props)
    this.state = {
      isToggleOn: true
    }
  }

  handleClick = () => {
    this.setState(state => ({
      isToggleOn: !state.isToggleOn
    }))
    this.test()
  }

  test() {
    console.log('this:', this)
  }

  render() {
    return (
      <button onClick={this.handleClick}>
        {this.state.isToggleOn ? 'NO' : 'OFF'}
      </button>
    )
  }
}

export default Toggle
